feat(rust/sedona-spatial-join) Making SpatialIndex a trait#645
feat(rust/sedona-spatial-join) Making SpatialIndex a trait#645pwrliang wants to merge 5 commits intoapache:mainfrom
Conversation
dcab75a to
085a047
Compare
Kontinuation
left a comment
There was a problem hiding this comment.
The refactoring for SpatialIndex looks good to me. BTW, I believe that SpatialIndexBuilder also need to be a trait.
| self.probe_threads_counter.fetch_sub(1, Ordering::Relaxed) == 1 | ||
| } | ||
|
|
||
| fn report_probe_completed(&self) -> bool; |
There was a problem hiding this comment.
We can do another pass of refactoring to move probe completion markers out of spatial index, this will simplify the interface of SpatialIndex. This does not need to be done in this PR.
|
Thank you for opening! I'm happy to take a look after the 0.3.0 release branch is created (hopefully Monday!). |
paleolimbot
left a comment
There was a problem hiding this comment.
Thank you!
I defer to @Kontinuation for the details (this may need another look as the builder trait was also added). I added a note about retaining documentation with the trait members rather than the implementation because I think they're most useful with the trait.
I'll also run copilot on this because I think it may help here!
There was a problem hiding this comment.
Pull request overview
This PR refactors the spatial-join indexing layer to introduce a SpatialIndex trait with a default implementation (DefaultSpatialIndex), enabling future alternative index backends (e.g., GPU-based) while keeping the current R-tree-based behavior as the default.
Changes:
- Split the previous concrete
SpatialIndexinto aSpatialIndextrait plusDefaultSpatialIndeximplementation, and introducedSpatialIndexRefas anArc<dyn ...>handle. - Split the previous concrete builder into a
SpatialIndexBuildertrait plusDefaultSpatialIndexBuilder. - Updated join stream/index-provider plumbing (and tests) to use the trait-object index handle instead of
Arc<SpatialIndex>.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| rust/sedona-spatial-join/src/stream.rs | Switches stream state and iterators to store/use SpatialIndexRef instead of a concrete index type. |
| rust/sedona-spatial-join/src/prepare.rs | Updates imports for build metrics after moving them under spatial_index_builder. |
| rust/sedona-spatial-join/src/lib.rs | Adjusts (and currently comments out) public re-exports related to index/build metrics. |
| rust/sedona-spatial-join/src/index/spatial_index_builder.rs | Introduces SpatialIndexBuilder trait and keeps SpatialJoinBuildMetrics. |
| rust/sedona-spatial-join/src/index/spatial_index.rs | Replaces concrete index implementation with SpatialIndex trait + SpatialIndexRef. |
| rust/sedona-spatial-join/src/index/partitioned_index_provider.rs | Migrates provider cache/build APIs to return SpatialIndexRef and uses DefaultSpatialIndexBuilder. |
| rust/sedona-spatial-join/src/index/default_spatial_index_builder.rs | New default builder implementing SpatialIndexBuilder and returning SpatialIndexRef. |
| rust/sedona-spatial-join/src/index/default_spatial_index.rs | New default index implementing SpatialIndex, moving prior index logic/tests here. |
| rust/sedona-spatial-join/src/index/build_side_collector.rs | Switches memory estimation call to DefaultSpatialIndexBuilder::estimate_extra_memory_usage. |
| rust/sedona-spatial-join/src/index.rs | Registers new index modules and re-exports DefaultSpatialIndexBuilder (currently as pub). |
Comments suppressed due to low confidence (2)
rust/sedona-spatial-join/src/index/spatial_index.rs:34
DISTANCE_TOLERANCEis declaredpubinside apub(crate)module under a privateindexmodule, so it isn’t effectively public. This may triggerunreachable_pubwarnings. Consider changing it topub(crate)(or re-export it from the crate root if it’s intended as public API).
pub const DISTANCE_TOLERANCE: f64 = 1e-9;
rust/sedona-spatial-join/src/index/spatial_index.rs:99
SpatialIndexRefis apubtype alias, but it lives in apub(crate)module under a privateindexmodule, so it isn’t effectively public and may triggerunreachable_pubwarnings. Consider changing it topub(crate)(internal use) or re-exporting it fromlib.rsif external consumers should be able to reference index handles.
pub type SpatialIndexRef = Arc<dyn SpatialIndex + Send + Sync>;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rust/sedona-spatial-join/src/index/default_spatial_index_builder.rs
Outdated
Show resolved
Hide resolved
c217bf7 to
2aaa1d2
Compare
|
I think I have addressed the above issues. I will open another PR to simplify the inteface of SpatialIndex, e.g., moving report_probe_completed, need_more_probe_stats out of SpatialIndex |
This PR splits
SpatialIndexinto a SpatialIndex trait and a default implementationDefaultSpatialIndex. These changes are for the upcoming GPU-based spatial join.